#pragma once
#include <memory>
#include <boost/signals2/signal.hpp>
#include <nice2d/updater.h>

class Timer : public Updater,public std::enable_shared_from_this<Timer>
{
public:
    Timer();
    ~Timer();
public:
    void start();
    void stop();

    void setInterval(float interval = 1.0f);
    float getInterval()const;

    void setRepeat(bool repeat = true);
    bool isRepeat()const;

    boost::signals2::signal<void(std::shared_ptr<Timer>)> timeout;

    void update(float deltaTime)override;
private:
    std::unique_ptr<class TimerData> data;
};
